#include "StdAfx.h"
#include "Vigenere.h"


Vigenere::Vigenere(const vector<int> & cle):_cle(cle)
{
}


Vigenere::~Vigenere(void)
{
}

string Vigenere::Chiffrer(const string str){
	string tmp = str;
	for (unsigned int i = 0; i< str.length();i++){
		tmp [i]= Coder(tmp[i],i);
	}
	return tmp;
}

string Vigenere::Dechiffrer(const string str){
	string tmp = str;
	for (unsigned int i = 0; i< str.length();i++){
		tmp [i]= Decoder(tmp[i],i);
	}
	return tmp;
}

char Vigenere::Coder(char c, int rang){
	return c + _cle[rang%_cle.size()];
}
char Vigenere::Decoder(char c, int rang){
	return c - _cle[rang%_cle.size()];
}